﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sahit.iSoilHotel.Domain.Seedwork.Specification;

namespace Sahit.iSoilHotel.Domain.MainBoundedContext.Tavern.Aggregates.RoomAgg
{
    public static class RoomSpecifications
    {
        public static Specification<Room> RoomSearch(int? roomStatusID, Guid? roomTypeID, string roomNumber)
        {
            Specification<Room> specification = new DirectSpecification<Room>(r=>true);

            if (roomStatusID != null)
            {
                var roomStatusIDSpec = new DirectSpecification<Room>(r => r.StatusID == roomStatusID);
                specification &= roomStatusIDSpec;
            }
            if (roomTypeID != Guid.Empty)
            {
                var roomTypeIDSpec = new DirectSpecification<Room>(r => r.RoomTypeID == roomTypeID);
                specification &= roomTypeIDSpec;
            }
            if(!String.IsNullOrEmpty(roomNumber))
            {
                var roomNumberSpec = new DirectSpecification<Room>(r => r.Number == roomNumber);
                specification &= roomNumberSpec;
            }

            return specification;
        }
    }
}
